var http = require('http');
const fs = require('fs');
http.createServer(function (request, response) {
  console.log(11, request.url)
  response.writeHead(200, {
    'content-type': 'text/html',
  });
  switch (request.url) {
    case '/':
      const homeStream = fs.createReadStream(__dirname + '/home.html');
      homeStream.pipe(response);
      break;
  
    case '/list':
      const listStream = fs.createReadStream(__dirname + '/list.html');
      listStream.pipe(response);
      break;
    default:
      response.end(`
        <!DOCTYPE html>
        <html lang="en">
        <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <meta http-equiv="X-UA-Compatible" content="ie=edge">
          <title>Document</title>
        </head>
        <body>
          我是无页面
        </body>
        </html>
      `)
      break;
  }
}).listen(8081);

console.log('Server running at http://127.0.0.1:8081/');